package com.my.app.service.impl;

import com.my.app.service.LogService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.springframework.stereotype.Service;

/**
 * Created by 80002023 on 2016/4/20.
 */
//@Service
public class LogServiceImpl implements LogService {

    private final Logger logger = LogManager.getLogger(getClass());

    public void log() {
        logger.debug("log service log with not args!");
    }

    public void logArg(JoinPoint point) {
        logger.debug("log service log with args : point !");
        //此方法返回的是一个数组，数组中包括request以及ActionCofig等类对象
        Object[] args = point.getArgs();
        logger.debug("目标参数列表：{}", args);
        if (args != null) {
            for (Object obj : args) {
                //logger.debug(obj + ",");
            }
        }
    }

    public void logArgAndReturn(JoinPoint point, Object returnObj) {
        logger.debug("log service log with args : point args {} and return object {} !", point.getArgs(), returnObj);
    }
}
